/*
 * @lc app=leetcode.cn id=2085 lang=typescript
 *
 * [2085] 统计出现过一次的公共字符串
 */

// @lc code=start
function countWords(words1: string[], words2: string[]): number {
    const findOnce = (words: string[]) => {
        return words.filter((i, index) => {
            return words.indexOf(i) === index && words.lastIndexOf(i) === index;
        });
    };
    words2 = findOnce(words2);
    words1 = findOnce(words1);

    return words1.filter((i) => words2.includes(i)).length;
}
// @lc code=end
